package n14_设计模式_固定顺序运行;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

/**
 * @author fu
 * @date 2022-01-11 21:25
 * 概要：
 * ----------------------------------------------------------------
 * |                                                              |
 * |              固定运行顺序---使用 park unpark 方法              |
 * |                                                            |
 * |=============================================================
 */
@Slf4j(topic = "c.T3")
public class T3_by_park {

    public static void main(String[] args) {


        final Thread t1 = new Thread(() -> {

            log.debug("进入park...");
            LockSupport.park();
            log.debug("-------------- t1 已运行");

        }, "t1");

        final Thread t2 = new Thread(() -> {

            log.debug("============== t2 已运行");
            LockSupport.unpark(t1);

        }, "t2");

        // 运行
        t1.start();
        t2.start();
    }
}
